//package com.photoeditor.demo.ui.dialog;
//
//import android.app.Dialog;
//import android.app.DialogFragment;
//import android.content.DialogInterface;
//import android.os.Bundle;
//import android.text.TextUtils;
//
//import com.photoeditor.demo.ad.AdItemBean;
//import com.photoeditor.demo.model.store.module.StoreOnlineBean;
//
///**
// * Created by dell on 2017/10/20.
// */
//
//public class DownloadDialogFragment extends DialogFragment {
//
//    DownloadAdDialog.OnActionListener mActionListener;
//    AdItemBean mAdItemBean;
//
//    public static DownloadDialogFragment newInstance(StoreOnlineBean storeOnlineBean, String adCache, int touchType) {
//
//        Bundle args = new Bundle();
//        args.putSerializable("storeOnlineBean", storeOnlineBean);
//        args.putString("adCacheKey", adCache);
//        args.putInt("touchType", touchType);
//        DownloadDialogFragment fragment = new DownloadDialogFragment();
//        fragment.setArguments(args);
//        return fragment;
//    }
//
//    @Override
//    public Dialog onCreateDialog(Bundle savedInstanceState) {
//        Bundle bundle = getArguments();
//        StoreOnlineBean storeOnlineBean = null;
//        AdItemBean adItemBean = mAdItemBean;
//        if (bundle != null) {
//            storeOnlineBean = (StoreOnlineBean) bundle.getSerializable("storeOnlineBean");
//            String adCacheKey = bundle.getString("adCacheKey");
//            int touchType = bundle.getInt("touchType");
//            if(!TextUtils.isEmpty(adCacheKey) && touchType != -1) {
//                adItemBean = new AdItemBean(adCacheKey);
//                adItemBean.setAdTouchType(touchType);
//            }
//        }
//        DownloadAdDialog downloadAdDialog = new DownloadAdDialog(getActivity(), storeOnlineBean, adItemBean);
//        downloadAdDialog.setOnActionListener(mActionListener);
//        return downloadAdDialog;
//    }
//
//    public void setListener(DownloadAdDialog.OnActionListener onActionListener) {
//        Dialog dialog = getDialog();
//        if (dialog instanceof DownloadAdDialog) {
//            ((DownloadAdDialog) dialog).setOnActionListener(onActionListener);
//        }
//        mActionListener = onActionListener;
//    }
//
//    public void refreshAd(AdItemBean adItemBean) {
//        Dialog dialog = getDialog();
//        if (dialog instanceof DownloadAdDialog) {
//            ((DownloadAdDialog) dialog).setAdCacheKey(adItemBean);
//        }
//        mAdItemBean = adItemBean;
//    }
//
//    @Override
//    public void onDismiss(DialogInterface dialog) {
//        super.onDismiss(dialog);
//        if (dialog instanceof DownloadAdDialog) {
//            ((DownloadAdDialog) dialog).onDismiss();
//        }
//    }
//}
